package com.test.fileupload;

import com.test.actionsupport.ActionSupport;
import lombok.Getter;
import lombok.Setter;

import java.io.File;
import java.util.List;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/9/13 11:32
 */
public class FileUploadAction extends ActionSupport {
    private static final long serialVersionUID = 3703396671449754910L;

    @Setter
    @Getter
    private List<File> ppt;

    @Getter
    @Setter
    private List<String> pptFileName;

    @Getter
    @Setter
    private List<String> pptContentType;

    @Setter
    @Getter
    private List<String> pptDesc;

    @Override
    public String execute() throws Exception {
        System.out.println(ppt);
        System.out.println(pptContentType);
        System.out.println(pptFileName);
        System.out.println(pptDesc);

//        ServletContext context = ServletActionContext.getServletContext();
//        String dir = context.getRealPath("/files/" + pptFileName);
        /*
        String dir = "D:\\Temp\\" + pptFileName;
        FileOutputStream outputStream = new FileOutputStream(dir);
        FileInputStream inputStream = new FileInputStream(ppt);
        byte[] buffer = new byte[1024];
        int len = 0;
        while ((len = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, len);
        }
        outputStream.close();
        inputStream.close();
        */

        return SUCCESS;
    }
}
